package com.evl.ticketKind.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.evl.common.controller.BaseController;
import com.evl.common.persistence.model.TicketKind;
import com.evl.ticketKind.dao.TicketKindDao;

/**
 * ticketKind控制器
 *
 * @author 
 * @Date 2017-06-22 18:46:02
 */
@Controller
@RequestMapping("/ticketKind")
public class TicketKindController extends BaseController {

    private String PREFIX = "/ticketKind/";
    
    @Resource
    private TicketKindDao ticketKindDao;

    /**
     * 跳转到ticketKind首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "ticketKind.html";
    }

    /**
     * 跳转到添加ticketKind
     */
    @RequestMapping("/ticketKind_add")
    public String ticketKindAdd() {
        return PREFIX + "ticketKind_add.html";
    }

    /**
     * 跳转到修改ticketKind
     */
    @RequestMapping("/ticketKind_update/{ticketKindId}")
    public String ticketKindUpdate(@PathVariable Integer ticketKindId, Model model) {
        return PREFIX + "ticketKind_edit.html";
    }

    /**
     * 获取ticketKind列表
     */
    @RequestMapping(value = "/all_list")
    @ResponseBody
    public Object allList() {
    	return ticketKindDao.selectAllTicketKinds();
    }
    
    /**
     * 获取ticketKind列表
     */
    @RequestMapping(value = "/kind_list")
    @ResponseBody
    public Object kindList(String kindCode) {
    	return ticketKindDao.selectKindTicketKinds(kindCode);
    }

    /**
     * 新增ticketKind
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TicketKind ticketKind) {
    	ticketKindDao.insert(ticketKind);
        return super.SUCCESS_TIP;
    }

    /**
     * 删除ticketKind
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(Integer id) {
    	ticketKindDao.deleteByPrimaryKey(id);
        return SUCCESS_TIP;
    }


    /**
     * 修改ticketKind
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TicketKind ticketKind) {
    	ticketKindDao.updateTicketKind(ticketKind);
        return super.SUCCESS_TIP;
    }

    /**
     * ticketKind详情
     */
    @RequestMapping(value = "/detail")
    @ResponseBody
    public Object detail(Integer id) {
    	return ticketKindDao.selectByPrimaryKey(id);
    }
}
